﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal;

namespace Chengheng.Entity.Models;

public partial class MyDbContext : DbContext
{
    public MyDbContext()
    {
    }

    public MyDbContext(DbContextOptions<MyDbContext> options)
        : base(options)
    {
    }

    public virtual DbSet<Commodity> CommodityCommodities { get; set; }

    public virtual DbSet<CommodityCommodityDetail> CommodityCommodityDetails { get; set; }

    public virtual DbSet<CommodityCommodityPicture> CommodityCommodityPictures { get; set; }

    public virtual DbSet<CommodityDictBrand> CommodityDictBrands { get; set; }

    public virtual DbSet<CommodityDictClassification> CommodityDictClassifications { get; set; }

    public virtual DbSet<CommodityDictColor> CommodityDictColors { get; set; }

    public virtual DbSet<CommodityDictListingyear> CommodityDictListingyears { get; set; }

    public virtual DbSet<CommodityDictPaymentmethod> CommodityDictPaymentmethods { get; set; }

    public virtual DbSet<CommodityDictSeason> CommodityDictSeasons { get; set; }

    public virtual DbSet<CommodityDictShop> CommodityDictShops { get; set; }

    public virtual DbSet<CommodityDictSize> CommodityDictSizes { get; set; }

    public virtual DbSet<CommodityDictSupplier> CommodityDictSuppliers { get; set; }

    public virtual DbSet<CommodityDictUnit> CommodityDictUnits { get; set; }

    public virtual DbSet<CommodityDictWarehouse> CommodityDictWarehouses { get; set; }

    public virtual DbSet<CommodityGroupColorgroup> CommodityGroupColorgroups { get; set; }

    public virtual DbSet<CommodityGroupSizegroup> CommodityGroupSizegroups { get; set; }

    public virtual DbSet<Course> Courses { get; set; }

    public virtual DbSet<Customer> Customers { get; set; }

    public virtual DbSet<CustomerCustomer> CustomerCustomers { get; set; }

    public virtual DbSet<CustomerCustomerPicture> CustomerCustomerPictures { get; set; }

    public virtual DbSet<EmployeeEmployee> EmployeeEmployees { get; set; }

    public virtual DbSet<EmployeeEmployeePicture> EmployeeEmployeePictures { get; set; }

    public virtual DbSet<FeedbackAdvice> FeedbackAdvices { get; set; }

    public virtual DbSet<FeedbackAdvicePicture> FeedbackAdvicePictures { get; set; }

    public virtual DbSet<FeedbackAdviceRemark> FeedbackAdviceRemarks { get; set; }

    public virtual DbSet<Order1> Order1s { get; set; }

    public virtual DbSet<PurchaseReturnorder> PurchaseReturnorders { get; set; }

    public virtual DbSet<PurchaseReturnorderDetail> PurchaseReturnorderDetails { get; set; }

    public virtual DbSet<PurchaseWarehousingorder> PurchaseWarehousingorders { get; set; }

    public virtual DbSet<PurchaseWarehousingorderDetail> PurchaseWarehousingorderDetails { get; set; }

    public virtual DbSet<SaleRetailorder> SaleRetailorders { get; set; }

    public virtual DbSet<SaleRetailorderPaymentmethod> SaleRetailorderPaymentmethods { get; set; }

    public virtual DbSet<SaleRetailorderitem> SaleRetailorderitems { get; set; }

    public virtual DbSet<StockInventoryorder> StockInventoryorders { get; set; }

    public virtual DbSet<StockInventoryorderItem> StockInventoryorderItems { get; set; }

    public virtual DbSet<StockStock> StockStocks { get; set; }

    public virtual DbSet<StockStockDetail> StockStockDetails { get; set; }

    public virtual DbSet<Student> Students { get; set; }

    public virtual DbSet<StudentActualCourse> StudentActualCourses { get; set; }

    public virtual DbSet<UserAuthority> UserAuthorities { get; set; }

    public virtual DbSet<UserRole> UserRoles { get; set; }

    public virtual DbSet<UserUser> UserUsers { get; set; }

    public virtual DbSet<UserUserPicture> UserUserPictures { get; set; }

    public virtual DbSet<UserUserVipsubscription> UserUserVipsubscriptions { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
        => optionsBuilder.UseMySql("server=localhost;port=3306;user=root;password=rootroot;database=chengheng_test", Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.4.3-mysql"));

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder
            .UseCollation("utf8mb4_0900_ai_ci")
            .HasCharSet("utf8mb4");

        modelBuilder.Entity<Commodity>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_commodity", tb => tb.HasComment("商品_商品"));

            entity.HasIndex(e => e.CommodityDictClassificationId, "FKhvqh8rrc3yj081stc6omygicl");

            entity.HasIndex(e => e.TenantId, "idx_commodity_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.BrandName)
                .HasMaxLength(50)
                .HasComment("品牌")
                .HasColumnName("brand_name");
            entity.Property(e => e.CommodityDictClassificationId)
                .HasComment("商品_字典_分类_id")
                .HasColumnName("commodity_dict_classification_id");
            entity.Property(e => e.CostPrice)
                .HasPrecision(10, 2)
                .HasComment("成本价格")
                .HasColumnName("cost_price");
            entity.Property(e => e.Discount)
                .HasPrecision(10, 2)
                .HasComment("折扣")
                .HasColumnName("discount");
            entity.Property(e => e.Integral)
                .HasComment("积分")
                .HasColumnName("integral");
            entity.Property(e => e.ListingYear)
                .HasMaxLength(4)
                .IsFixedLength()
                .HasComment("上市年份")
                .HasColumnName("listing_year");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("品名")
                .HasColumnName("name");
            entity.Property(e => e.SeasonName)
                .HasMaxLength(50)
                .HasComment("季节名称")
                .HasColumnName("season_name");
            entity.Property(e => e.Shelf)
                .HasComment("是否上架")
                .HasColumnName("shelf");
            entity.Property(e => e.StyleNumber)
                .HasMaxLength(255)
                .HasComment("款号")
                .HasColumnName("style_number");
            entity.Property(e => e.TagPrice)
                .HasPrecision(10, 2)
                .HasComment("吊牌价")
                .HasColumnName("tag_price");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
            entity.Property(e => e.TotalQuantity)
                .HasComment("总数量")
                .HasColumnName("total_quantity");
            entity.Property(e => e.TotalTagPrice)
                .HasPrecision(38, 2)
                .HasComment("总吊牌价格")
                .HasColumnName("total_tag_price");
            entity.Property(e => e.UnitName)
                .HasMaxLength(50)
                .HasComment("单位")
                .HasColumnName("unit_name");

            entity.HasOne(d => d.CommodityDictClassification).WithMany(p => p.CommodityCommodities)
                .HasForeignKey(d => d.CommodityDictClassificationId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("FKhvqh8rrc3yj081stc6omygicl");
        });

        modelBuilder.Entity<CommodityCommodityDetail>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_commodity_details", tb => tb.HasComment("商品_商品_详情"));

            entity.HasIndex(e => e.CommodityCommodityId, "FK48tp4mhxhtuu3imgj5w839o27");

            entity.HasIndex(e => e.TenantId, "idx_commoditydetails");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.BarCode)
                .HasMaxLength(50)
                .HasComment("条码")
                .HasColumnName("barCode");
            entity.Property(e => e.Color)
                .HasMaxLength(50)
                .HasComment("颜色")
                .HasColumnName("color");
            entity.Property(e => e.CommodityCommodityId)
                .HasComment("商品_商品_id")
                .HasColumnName("commodity_commodity_id");
            entity.Property(e => e.Quantity)
                .HasComment("数量")
                .HasColumnName("quantity");
            entity.Property(e => e.Size)
                .HasMaxLength(50)
                .HasComment("尺码")
                .HasColumnName("size");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");

            entity.HasOne(d => d.Commodity).WithMany(p => p.CommodityCommodityDetails)
                .HasForeignKey(d => d.CommodityCommodityId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("FK48tp4mhxhtuu3imgj5w839o27");
        });

        modelBuilder.Entity<CommodityCommodityPicture>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_commodity_picture", tb => tb.HasComment("商品_商品_图片"));

            entity.HasIndex(e => e.CommodityCommodityId, "UK54hluwxsfwq6ephdm2k1m9yod").IsUnique();

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CommodityCommodityId)
                .HasComment("隶属于哪个商品")
                .HasColumnName("commodity_commodity_id");
            entity.Property(e => e.ObjectKey)
                .HasMaxLength(1024)
                .HasComment("保存对象存储的key")
                .HasColumnName("object_key");

            entity.HasOne(d => d.Commodity).WithOne(p => p.CommodityCommodityPicture)
                .HasForeignKey<CommodityCommodityPicture>(d => d.CommodityCommodityId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("FKsoef6e1awsgfipo5e2e4s8vd5");
        });

        modelBuilder.Entity<CommodityDictBrand>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_dict_brand", tb => tb.HasComment("商品_字典_品牌"));

            entity.HasIndex(e => e.TenantId, "idx_brand_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("品牌名称")
                .HasColumnName("name");
            entity.Property(e => e.SortNumber)
                .HasComment("排序号")
                .HasColumnName("sort_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
        });

        modelBuilder.Entity<CommodityDictClassification>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_dict_classification", tb => tb.HasComment("商品_字典_分类"));

            entity.HasIndex(e => e.ParentId, "FKdyfscmc30qlbhggwgjbfr8gnf");

            entity.HasIndex(e => e.TenantId, "idx_classification_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("分类名称")
                .HasColumnName("name");
            entity.Property(e => e.ParentId).HasColumnName("parent_id");
            entity.Property(e => e.SortNumber)
                .HasComment("排序号")
                .HasColumnName("sort_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");

            entity.HasOne(d => d.Parent).WithMany(p => p.InverseParent)
                .HasForeignKey(d => d.ParentId)
                .HasConstraintName("FKdyfscmc30qlbhggwgjbfr8gnf");
        });

        modelBuilder.Entity<CommodityDictColor>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_dict_color", tb => tb.HasComment("商品_字典_颜色"));

            entity.HasIndex(e => e.TenantId, "idx_color_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("颜色名称")
                .HasColumnName("name");
            entity.Property(e => e.SortNumber)
                .HasComment("排序号")
                .HasColumnName("sort_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
        });

        modelBuilder.Entity<CommodityDictListingyear>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_dict_listingyear", tb => tb.HasComment("商品_字典_上市年份"));

            entity.HasIndex(e => e.TenantId, "idx_listingyear_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("上市年份名称")
                .HasColumnName("name");
            entity.Property(e => e.SortNumber)
                .HasComment("排序号")
                .HasColumnName("sort_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
        });

        modelBuilder.Entity<CommodityDictPaymentmethod>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_dict_paymentmethod", tb => tb.HasComment("商品_字典_付款方式"));

            entity.HasIndex(e => e.TenantId, "idx_paymentmethod_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("支付方式名称")
                .HasColumnName("name");
            entity.Property(e => e.SortNumber)
                .HasComment("排序号")
                .HasColumnName("sort_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
        });

        modelBuilder.Entity<CommodityDictSeason>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_dict_season", tb => tb.HasComment("商品_字典_季节"));

            entity.HasIndex(e => e.TenantId, "idx_season_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("季节名称")
                .HasColumnName("name");
            entity.Property(e => e.SortNumber)
                .HasComment("排序号")
                .HasColumnName("sort_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
        });

        modelBuilder.Entity<CommodityDictShop>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_dict_shop", tb => tb.HasComment("商品_字典_门店"));

            entity.HasIndex(e => e.TenantId, "idx_shop_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.IsDefaultName)
                .HasColumnType("bit(1)")
                .HasColumnName("is_default_name");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("门店名称")
                .HasColumnName("name");
            entity.Property(e => e.SortNumber)
                .HasComment("排序号")
                .HasColumnName("sort_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
        });

        modelBuilder.Entity<CommodityDictSize>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_dict_size", tb => tb.HasComment("商品_字典_尺码"));

            entity.HasIndex(e => e.TenantId, "idx_size_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("尺码名称")
                .HasColumnName("name");
            entity.Property(e => e.SortNumber)
                .HasComment("排序号")
                .HasColumnName("sort_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
        });

        modelBuilder.Entity<CommodityDictSupplier>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_dict_supplier", tb => tb.HasComment("商品_字典_供应商"));

            entity.HasIndex(e => e.TenantId, "idx_supplier_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.IsDefaultName)
                .HasColumnType("bit(1)")
                .HasColumnName("is_default_name");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("供应商名称")
                .HasColumnName("name");
            entity.Property(e => e.SortNumber)
                .HasComment("排序号")
                .HasColumnName("sort_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
        });

        modelBuilder.Entity<CommodityDictUnit>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_dict_unit", tb => tb.HasComment("商品_字典_单位"));

            entity.HasIndex(e => e.TenantId, "idx_unit_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("单位名称")
                .HasColumnName("name");
            entity.Property(e => e.SortNumber)
                .HasComment("排序号")
                .HasColumnName("sort_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
        });

        modelBuilder.Entity<CommodityDictWarehouse>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_dict_warehouse", tb => tb.HasComment("商品_字典_仓库"));

            entity.HasIndex(e => e.TenantId, "idx_warehouse_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.IsDefaultName)
                .HasColumnType("bit(1)")
                .HasColumnName("is_default_name");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("仓库名称")
                .HasColumnName("name");
            entity.Property(e => e.SortNumber)
                .HasComment("排序号")
                .HasColumnName("sort_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
        });

        modelBuilder.Entity<CommodityGroupColorgroup>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_group_colorgroup", tb => tb.HasComment("商品_字典_颜色组"));

            entity.HasIndex(e => e.TenantId, "idx_colorgroup_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("颜色的名字")
                .HasColumnName("name");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");

            entity.HasMany(d => d.CommodityDictColors).WithMany(p => p.CommodityGroupColorgroups)
                .UsingEntity<Dictionary<string, object>>(
                    "CommodityGroupColorgroupManyCommodityDictColor",
                    r => r.HasOne<CommodityDictColor>().WithMany()
                        .HasForeignKey("CommodityDictColorId")
                        .OnDelete(DeleteBehavior.ClientSetNull)
                        .HasConstraintName("FK49pvfl9xejkrmmij8llpovi31"),
                    l => l.HasOne<CommodityGroupColorgroup>().WithMany()
                        .HasForeignKey("CommodityGroupColorgroupId")
                        .OnDelete(DeleteBehavior.ClientSetNull)
                        .HasConstraintName("FKa7v7x76nx69gd1qo5ii0r15jb"),
                    j =>
                    {
                        j.HasKey("CommodityGroupColorgroupId", "CommodityDictColorId")
                            .HasName("PRIMARY")
                            .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 });
                        j.ToTable("commodity_group_colorgroup_many_commodity_dict_color");
                        j.HasIndex(new[] { "CommodityDictColorId" }, "FK49pvfl9xejkrmmij8llpovi31");
                        j.IndexerProperty<long>("CommodityGroupColorgroupId").HasColumnName("commodity_group_colorgroup_id");
                        j.IndexerProperty<long>("CommodityDictColorId").HasColumnName("commodity_dict_Color_id");
                    });
        });

        modelBuilder.Entity<CommodityGroupSizegroup>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("commodity_group_sizegroup", tb => tb.HasComment("商品_字典_尺码组"));

            entity.HasIndex(e => e.TenantId, "idx_sizegroup_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasComment("尺码组的名称")
                .HasColumnName("name");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");

            entity.HasMany(d => d.CommodityDictSizes).WithMany(p => p.CommodityGroupSizegroups)
                .UsingEntity<Dictionary<string, object>>(
                    "CommodityGroupSizegroupManyCommodityDictSize",
                    r => r.HasOne<CommodityDictSize>().WithMany()
                        .HasForeignKey("CommodityDictSizeId")
                        .OnDelete(DeleteBehavior.ClientSetNull)
                        .HasConstraintName("FK1xdcj85vvho4wdrd92njo2rfd"),
                    l => l.HasOne<CommodityGroupSizegroup>().WithMany()
                        .HasForeignKey("CommodityGroupSizegroupId")
                        .OnDelete(DeleteBehavior.ClientSetNull)
                        .HasConstraintName("FK3fe29ly5heag6sbrwix2t83td"),
                    j =>
                    {
                        j.HasKey("CommodityGroupSizegroupId", "CommodityDictSizeId")
                            .HasName("PRIMARY")
                            .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 });
                        j.ToTable("commodity_group_sizegroup_many_commodity_dict_size");
                        j.HasIndex(new[] { "CommodityDictSizeId" }, "FK1xdcj85vvho4wdrd92njo2rfd");
                        j.IndexerProperty<long>("CommodityGroupSizegroupId").HasColumnName("commodity_group_sizegroup_id");
                        j.IndexerProperty<long>("CommodityDictSizeId").HasColumnName("commodity_dict_size_id");
                    });
        });

        modelBuilder.Entity<Course>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("Course");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
            entity.Property(e => e.TenantId).HasColumnName("tenantId");

            entity.HasMany(d => d.Students).WithMany(p => p.Courses)
                .UsingEntity<Dictionary<string, object>>(
                    "StudentCourse",
                    r => r.HasOne<Student>().WithMany()
                        .HasForeignKey("StudentId")
                        .OnDelete(DeleteBehavior.ClientSetNull)
                        .HasConstraintName("FKpwtumr5ofgydxbuhmvdql4fye"),
                    l => l.HasOne<Course>().WithMany()
                        .HasForeignKey("CourseId")
                        .OnDelete(DeleteBehavior.ClientSetNull)
                        .HasConstraintName("FKtao0ysp4xfmi9dlxc10ku58qq"),
                    j =>
                    {
                        j.HasKey("CourseId", "StudentId")
                            .HasName("PRIMARY")
                            .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 });
                        j.ToTable("student_course");
                        j.HasIndex(new[] { "StudentId" }, "FKpwtumr5ofgydxbuhmvdql4fye");
                        j.IndexerProperty<long>("CourseId").HasColumnName("course_id");
                        j.IndexerProperty<long>("StudentId").HasColumnName("student_id");
                    });
        });

        modelBuilder.Entity<Customer>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("Customer");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
        });

        modelBuilder.Entity<CustomerCustomer>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("customer_customer", tb => tb.HasComment("顾客_顾客"));

            entity.HasIndex(e => e.PhoneNumber, "idx_customer_phone_number");

            entity.HasIndex(e => e.TenantId, "idx_customer_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Integral)
                .HasComment("积分")
                .HasColumnName("integral");
            entity.Property(e => e.IsDefaultName)
                .HasColumnType("bit(1)")
                .HasColumnName("is_default_name");
            entity.Property(e => e.Level)
                .HasMaxLength(50)
                .HasComment("顾客的消费级别")
                .HasColumnName("level");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("顾客姓名")
                .HasColumnName("name");
            entity.Property(e => e.PhoneNumber)
                .HasMaxLength(50)
                .HasComment("手机号码")
                .HasColumnName("phone_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
        });

        modelBuilder.Entity<CustomerCustomerPicture>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("customer_customer_picture", tb => tb.HasComment("顾客_顾客_图片"));

            entity.HasIndex(e => e.CustomerCustomerId, "UKhyohiieiu59mqvrwgihc0clfp").IsUnique();

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CustomerCustomerId)
                .HasComment("隶属于哪个顾客")
                .HasColumnName("customer_customer_id");
            entity.Property(e => e.ObjectKey)
                .HasMaxLength(1024)
                .HasComment("保存对象存储的key")
                .HasColumnName("object_key");

            entity.HasOne(d => d.CustomerCustomer).WithOne(p => p.CustomerCustomerPicture)
                .HasForeignKey<CustomerCustomerPicture>(d => d.CustomerCustomerId)
                .HasConstraintName("FKji3slfj3bajbsc2lb9vb68sk2");
        });

        modelBuilder.Entity<EmployeeEmployee>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("employee_employee", tb => tb.HasComment("雇员_雇员"));

            entity.HasIndex(e => e.PhoneNumber, "idx_employee_phone_number");

            entity.HasIndex(e => e.TenantId, "idx_employee_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.IsDefaultName)
                .HasColumnType("bit(1)")
                .HasColumnName("is_default_name");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("店员姓名")
                .HasColumnName("name");
            entity.Property(e => e.PhoneNumber)
                .HasMaxLength(11)
                .HasComment("手机号码")
                .HasColumnName("phone_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
        });

        modelBuilder.Entity<EmployeeEmployeePicture>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("employee_employee_picture", tb => tb.HasComment("员工_员工_图片"));

            entity.HasIndex(e => e.PictureId, "UK3gnugox0niefp0w8xrv4t2cce").IsUnique();

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.ObjectKey)
                .HasMaxLength(1024)
                .HasComment("保存对象存储的key")
                .HasColumnName("object_key");
            entity.Property(e => e.PictureId).HasColumnName("picture_id");

            entity.HasOne(d => d.Picture).WithOne(p => p.EmployeeEmployeePicture)
                .HasForeignKey<EmployeeEmployeePicture>(d => d.PictureId)
                .HasConstraintName("FKndvw09y7qd5uf880m6x3n6uyq");
        });

        modelBuilder.Entity<FeedbackAdvice>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("feedback_advice", tb => tb.HasComment("反馈_建议"));

            entity.HasIndex(e => e.TenantId, "idx_advice_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Audit)
                .HasComment("是否审核 0 未审核 1 审核")
                .HasColumnName("audit");
            entity.Property(e => e.Content)
                .HasComment("建议的详情内容")
                .HasColumnType("text")
                .HasColumnName("content");
            entity.Property(e => e.DateTime)
                .HasComment("提交的日期")
                .HasColumnType("datetime")
                .HasColumnName("date_time");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
            entity.Property(e => e.Title)
                .HasComment("标题内容")
                .HasColumnType("text")
                .HasColumnName("title");
        });

        modelBuilder.Entity<FeedbackAdvicePicture>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("feedback_advice_picture", tb => tb.HasComment("反馈_建议_图片"));

            entity.HasIndex(e => e.FeedbackAdviceId, "FKknx064qoecj9umbk6mkbc6s4k");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.FeedbackAdviceId)
                .HasComment("反馈_建议_id")
                .HasColumnName("feedback_advice_id");
            entity.Property(e => e.ObjectKey)
                .HasMaxLength(1024)
                .HasComment("保存对象存储的key")
                .HasColumnName("object_key");

            entity.HasOne(d => d.FeedbackAdvice).WithMany(p => p.FeedbackAdvicePictures)
                .HasForeignKey(d => d.FeedbackAdviceId)
                .HasConstraintName("FKknx064qoecj9umbk6mkbc6s4k");
        });

        modelBuilder.Entity<FeedbackAdviceRemark>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("feedback_advice_remark", tb => tb.HasComment("反馈_建议_评论"));

            entity.HasIndex(e => e.FeedbackAdviceId, "FKpj95m6x4fc72gw4q8a13glu1x");

            entity.HasIndex(e => e.TenantId, "idx_remark_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Content)
                .HasMaxLength(255)
                .HasComment("评论内容")
                .HasColumnName("content");
            entity.Property(e => e.CreateTime)
                .HasColumnType("datetime")
                .HasColumnName("create_time");
            entity.Property(e => e.FeedbackAdviceId)
                .HasComment("反馈_建议_id")
                .HasColumnName("feedback_advice_id");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");

            entity.HasOne(d => d.FeedbackAdvice).WithMany(p => p.FeedbackAdviceRemarks)
                .HasForeignKey(d => d.FeedbackAdviceId)
                .HasConstraintName("FKpj95m6x4fc72gw4q8a13glu1x");
        });

        modelBuilder.Entity<Order1>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("order1");

            entity.HasIndex(e => e.CustomerId, "FKga2fuoppx916s4endomtsroa4");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CustomerId).HasColumnName("customer_id");
            entity.Property(e => e.Description)
                .HasMaxLength(255)
                .HasColumnName("description");

            entity.HasOne(d => d.Customer).WithMany(p => p.Order1s)
                .HasForeignKey(d => d.CustomerId)
                .HasConstraintName("FKga2fuoppx916s4endomtsroa4");
        });

        modelBuilder.Entity<PurchaseReturnorder>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("purchase_returnorder", tb => tb.HasComment("采购_退货单"));

            entity.HasIndex(e => e.TenantId, "idx_returnorder_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.ActualAmount)
                .HasPrecision(10, 2)
                .HasComment("实付金额")
                .HasColumnName("actual_amount");
            entity.Property(e => e.Audit)
                .HasComment("是否审核 0 未审核 1 审核")
                .HasColumnName("audit");
            entity.Property(e => e.AuditDate)
                .HasComment("采购审核日期")
                .HasColumnName("audit_date");
            entity.Property(e => e.Date)
                .HasComment("采购入库日期")
                .HasColumnName("date");
            entity.Property(e => e.DiscountAmount)
                .HasPrecision(10, 2)
                .HasComment("优惠金额")
                .HasColumnName("discount_amount");
            entity.Property(e => e.DueAmount)
                .HasPrecision(10, 2)
                .HasComment("应付金额")
                .HasColumnName("due_amount");
            entity.Property(e => e.OwedAmount)
                .HasPrecision(10, 2)
                .HasComment("欠款金额")
                .HasColumnName("owed_amount");
            entity.Property(e => e.PaymentMethod)
                .HasMaxLength(50)
                .HasComment("付款方式")
                .HasColumnName("payment_method");
            entity.Property(e => e.Shop)
                .HasMaxLength(50)
                .HasComment("门店")
                .HasColumnName("shop");
            entity.Property(e => e.Supplier)
                .HasMaxLength(50)
                .HasComment("供应商")
                .HasColumnName("supplier");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
            entity.Property(e => e.TicketNumber)
                .HasMaxLength(255)
                .HasComment("票号")
                .HasColumnName("ticket_number");
            entity.Property(e => e.TotalQuantity)
                .HasComment("总数量")
                .HasColumnName("total_quantity");
            entity.Property(e => e.Warehouse)
                .HasMaxLength(50)
                .HasComment("仓库")
                .HasColumnName("warehouse");
        });

        modelBuilder.Entity<PurchaseReturnorderDetail>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("purchase_returnorder_details", tb => tb.HasComment("采购_退货单_详情"));

            entity.HasIndex(e => e.CommodityCommodityId, "FKdtx2kx5u8im5a0k2hiuay2fh6");

            entity.HasIndex(e => e.PurchaseReturnorderId, "FKktgjett3ywv3n8dto7nooyfpl");

            entity.HasIndex(e => e.TenantId, "idx_returnorderdetails");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Color)
                .HasMaxLength(50)
                .HasComment("颜色")
                .HasColumnName("color");
            entity.Property(e => e.CommodityCommodityId)
                .HasComment("商品_商品_id")
                .HasColumnName("commodity_commodity_id");
            entity.Property(e => e.PurchaseReturnorderId)
                .HasComment("采购_退货单_id")
                .HasColumnName("purchase_returnorder_id");
            entity.Property(e => e.Quantity)
                .HasComment("当前的数量")
                .HasColumnName("quantity");
            entity.Property(e => e.Size)
                .HasMaxLength(50)
                .HasComment("尺码")
                .HasColumnName("size");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");

            entity.HasOne(d => d.CommodityCommodity).WithMany(p => p.PurchaseReturnorderDetails)
                .HasForeignKey(d => d.CommodityCommodityId)
                .HasConstraintName("FKdtx2kx5u8im5a0k2hiuay2fh6");

            entity.HasOne(d => d.PurchaseReturnorder).WithMany(p => p.PurchaseReturnorderDetails)
                .HasForeignKey(d => d.PurchaseReturnorderId)
                .HasConstraintName("FKktgjett3ywv3n8dto7nooyfpl");
        });

        modelBuilder.Entity<PurchaseWarehousingorder>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("purchase_warehousingorder", tb => tb.HasComment("采购_入库单"));

            entity.HasIndex(e => e.TenantId, "idx_warehousingorder");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.ActualAmount)
                .HasPrecision(10, 2)
                .HasComment("实付金额")
                .HasColumnName("actual_amount");
            entity.Property(e => e.Audit)
                .HasComment("是否审核 0 未审核 1 审核")
                .HasColumnName("audit");
            entity.Property(e => e.AuditDate)
                .HasComment("采购审核日期")
                .HasColumnName("audit_date");
            entity.Property(e => e.Date)
                .HasComment("采购入库日期")
                .HasColumnName("date");
            entity.Property(e => e.DiscountAmount)
                .HasPrecision(10, 2)
                .HasComment("优惠金额")
                .HasColumnName("discount_amount");
            entity.Property(e => e.DueAmount)
                .HasPrecision(10, 2)
                .HasComment("应付金额")
                .HasColumnName("due_amount");
            entity.Property(e => e.OwedAmount)
                .HasPrecision(10, 2)
                .HasComment("欠款金额")
                .HasColumnName("owed_amount");
            entity.Property(e => e.PaymentMethod)
                .HasMaxLength(50)
                .HasComment("付款方式")
                .HasColumnName("payment_method");
            entity.Property(e => e.Shop)
                .HasMaxLength(50)
                .HasComment("门店")
                .HasColumnName("shop");
            entity.Property(e => e.Supplier)
                .HasMaxLength(50)
                .HasComment("供应商")
                .HasColumnName("supplier");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
            entity.Property(e => e.TicketNumber)
                .HasMaxLength(255)
                .HasComment("票号")
                .HasColumnName("ticket_number");
            entity.Property(e => e.TotalQuantity)
                .HasComment("总数量")
                .HasColumnName("total_quantity");
            entity.Property(e => e.Warehouse)
                .HasMaxLength(50)
                .HasComment("仓库")
                .HasColumnName("warehouse");
        });

        modelBuilder.Entity<PurchaseWarehousingorderDetail>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("purchase_warehousingorder_details", tb => tb.HasComment("采购_入库单_详情"));

            entity.HasIndex(e => e.CommodityCommodityId, "FKjqhbff510mgnsfn9x4hcctjlf");

            entity.HasIndex(e => e.PurchaseWarehousingorderId, "FKlnw4ey7krckfegmtaroug88ym");

            entity.HasIndex(e => e.TenantId, "idx_warehousingorderdetails");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Color)
                .HasMaxLength(50)
                .HasComment("颜色")
                .HasColumnName("color");
            entity.Property(e => e.CommodityCommodityId)
                .HasComment("商品_商品_id")
                .HasColumnName("commodity_commodity_id");
            entity.Property(e => e.PurchaseWarehousingorderId)
                .HasComment("采购_入库单_id")
                .HasColumnName("purchase_warehousingorder_id");
            entity.Property(e => e.Quantity)
                .HasComment("当前的数量")
                .HasColumnName("quantity");
            entity.Property(e => e.Size)
                .HasMaxLength(50)
                .HasComment("尺码")
                .HasColumnName("size");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");

            entity.HasOne(d => d.CommodityCommodity).WithMany(p => p.PurchaseWarehousingorderDetails)
                .HasForeignKey(d => d.CommodityCommodityId)
                .HasConstraintName("FKjqhbff510mgnsfn9x4hcctjlf");

            entity.HasOne(d => d.PurchaseWarehousingorder).WithMany(p => p.PurchaseWarehousingorderDetails)
                .HasForeignKey(d => d.PurchaseWarehousingorderId)
                .HasConstraintName("FKlnw4ey7krckfegmtaroug88ym");
        });

        modelBuilder.Entity<SaleRetailorder>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("sale_retailorder", tb => tb.HasComment("销售_零售单"));

            entity.HasIndex(e => e.EmployeeEmployeeId, "FKbqj2qdw8rkjiuu4kxryfebbg5");

            entity.HasIndex(e => e.CustomerCustomerId, "FKqvmwf66q9277ftj2iosydyams");

            entity.HasIndex(e => e.TenantId, "idx_retailorder_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CustomerCustomerId)
                .HasComment("顾客_信息_id")
                .HasColumnName("customer_customer_id");
            entity.Property(e => e.Date)
                .HasComment("销售日期")
                .HasColumnName("date");
            entity.Property(e => e.Discount)
                .HasPrecision(38, 2)
                .HasComment("折扣-存入的数字是百分比")
                .HasColumnName("discount");
            entity.Property(e => e.EmployeeEmployeeId)
                .HasComment("雇员_店员_id")
                .HasColumnName("employee_employee_id");
            entity.Property(e => e.ReceivableAmount)
                .HasPrecision(10, 2)
                .HasComment("应收金额")
                .HasColumnName("receivable_amount");
            entity.Property(e => e.ReceivedAmount)
                .HasPrecision(10, 2)
                .HasComment("实收金额")
                .HasColumnName("received_amount");
            entity.Property(e => e.Status)
                .HasComment("状态: 0 挂单 1 未完成 1 已完成\n")
                .HasColumnName("status");
            entity.Property(e => e.Store)
                .HasMaxLength(50)
                .HasComment("门店")
                .HasColumnName("store");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
            entity.Property(e => e.TicketNumber)
                .HasMaxLength(50)
                .HasComment("零售票号")
                .HasColumnName("ticket_number");
            entity.Property(e => e.TotalNumber)
                .HasComment("总数量")
                .HasColumnName("total_number");
            entity.Property(e => e.Warehouse)
                .HasMaxLength(50)
                .HasComment("出货仓库")
                .HasColumnName("warehouse");

            entity.HasOne(d => d.CustomerCustomer).WithMany(p => p.SaleRetailorders)
                .HasForeignKey(d => d.CustomerCustomerId)
                .HasConstraintName("FKqvmwf66q9277ftj2iosydyams");

            entity.HasOne(d => d.EmployeeEmployee).WithMany(p => p.SaleRetailorders)
                .HasForeignKey(d => d.EmployeeEmployeeId)
                .HasConstraintName("FKbqj2qdw8rkjiuu4kxryfebbg5");
        });

        modelBuilder.Entity<SaleRetailorderPaymentmethod>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("sale_retailorder_paymentmethod", tb => tb.HasComment("销售_零售单_金额"));

            entity.HasIndex(e => e.CommodityDictPaymentmethodId, "FKavqmcio0bjqpxqo3inpjc649a");

            entity.HasIndex(e => e.SaleRetailorderId, "FKcemfu7d2uky8beq2wh06xssqi");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CommodityDictPaymentmethodId).HasColumnName("commodity_dict_paymentmethod_id");
            entity.Property(e => e.PaymentAmount)
                .HasPrecision(10, 2)
                .HasColumnName("payment_amount");
            entity.Property(e => e.SaleRetailorderId).HasColumnName("sale_retailorder_id");

            entity.HasOne(d => d.CommodityDictPaymentmethod).WithMany(p => p.SaleRetailorderPaymentmethods)
                .HasForeignKey(d => d.CommodityDictPaymentmethodId)
                .HasConstraintName("FKavqmcio0bjqpxqo3inpjc649a");

            entity.HasOne(d => d.SaleRetailorder).WithMany(p => p.SaleRetailorderPaymentmethods)
                .HasForeignKey(d => d.SaleRetailorderId)
                .HasConstraintName("FKcemfu7d2uky8beq2wh06xssqi");
        });

        modelBuilder.Entity<SaleRetailorderitem>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("sale_retailorderitem", tb => tb.HasComment("销售_零售单条目"));

            entity.HasIndex(e => e.CommodityCommodityId, "FKdftiw77vguupfi7ccwmiifhbs");

            entity.HasIndex(e => e.SaleRetailorderId, "FKhwhjnhb39tus6gc6livkffgy3");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Color)
                .HasMaxLength(50)
                .HasComment("颜色")
                .HasColumnName("color");
            entity.Property(e => e.CommodityCommodityId)
                .HasComment("商品_商品_id")
                .HasColumnName("commodity_commodity_id");
            entity.Property(e => e.Quantity)
                .HasComment("当前的数量")
                .HasColumnName("quantity");
            entity.Property(e => e.SaleRetailorderId).HasColumnName("sale_retailorder_id");
            entity.Property(e => e.Size)
                .HasMaxLength(50)
                .HasComment("尺码")
                .HasColumnName("size");

            entity.HasOne(d => d.CommodityCommodity).WithMany(p => p.SaleRetailorderitems)
                .HasForeignKey(d => d.CommodityCommodityId)
                .HasConstraintName("FKdftiw77vguupfi7ccwmiifhbs");

            entity.HasOne(d => d.SaleRetailorder).WithMany(p => p.SaleRetailorderitems)
                .HasForeignKey(d => d.SaleRetailorderId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("FKhwhjnhb39tus6gc6livkffgy3");
        });

        modelBuilder.Entity<StockInventoryorder>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("stock_inventoryorder", tb => tb.HasComment("库存_盘点单"));

            entity.HasIndex(e => e.CommodityDictWarehouseId, "FKl3f3o9j8icrj6qnrl9xcm0dte");

            entity.HasIndex(e => e.TenantId, "idx_inventoryorder_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Audit)
                .HasComment("0 未审核 1 审核 ")
                .HasColumnName("audit");
            entity.Property(e => e.AuditDate)
                .HasComment("审核日期")
                .HasColumnName("audit_date");
            entity.Property(e => e.CommodityDictWarehouseId)
                .HasComment("字典_仓库_id")
                .HasColumnName("commodity_dict_warehouse_id");
            entity.Property(e => e.Date)
                .HasComment("盘点日期")
                .HasColumnName("date");
            entity.Property(e => e.InventoryType)
                .HasComment("0 部分判断 1 全部盘点 ")
                .HasColumnName("inventory_type");
            entity.Property(e => e.Shop)
                .HasMaxLength(50)
                .HasComment("门店")
                .HasColumnName("shop");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
            entity.Property(e => e.TicketNumber)
                .HasMaxLength(50)
                .HasComment("盘点单号")
                .HasColumnName("ticket_number");
            entity.Property(e => e.TotalQuantityDifference)
                .HasComment("差异总数量")
                .HasColumnName("total_quantity_difference");
            entity.Property(e => e.TotalQuantityInventory)
                .HasComment("盘点总数量")
                .HasColumnName("total_quantity_inventory");
            entity.Property(e => e.TotalQuantityStock)
                .HasComment("库存的总数量")
                .HasColumnName("total_quantity_stock");

            entity.HasOne(d => d.CommodityDictWarehouse).WithMany(p => p.StockInventoryorders)
                .HasForeignKey(d => d.CommodityDictWarehouseId)
                .HasConstraintName("FKl3f3o9j8icrj6qnrl9xcm0dte");
        });

        modelBuilder.Entity<StockInventoryorderItem>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("stock_inventoryorder_item", tb => tb.HasComment("库存_盘点单_详情"));

            entity.HasIndex(e => e.CommodityCommodityId, "FKc1x6sikhuo1b7n0xjig8uduc");

            entity.HasIndex(e => e.StockInventoryInventoryorderId, "FKfgw3hk1uk08d0v9fwy5erhl33");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Color)
                .HasMaxLength(50)
                .HasComment("颜色")
                .HasColumnName("color");
            entity.Property(e => e.CommodityCommodityId)
                .HasComment("商品_商品_id")
                .HasColumnName("commodity_commodity_id");
            entity.Property(e => e.DifferenceQuantity)
                .HasComment("差异数量")
                .HasColumnName("difference_quantity");
            entity.Property(e => e.InventoryQuantity)
                .HasComment("盘点数量")
                .HasColumnName("inventory_quantity");
            entity.Property(e => e.Quantity)
                .HasComment("当前的数量")
                .HasColumnName("quantity");
            entity.Property(e => e.Size)
                .HasMaxLength(50)
                .HasComment("尺码")
                .HasColumnName("size");
            entity.Property(e => e.StockInventoryInventoryorderId)
                .HasComment("库存_盘点单_id")
                .HasColumnName("stock_inventory_inventoryorder_id");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");

            entity.HasOne(d => d.CommodityCommodity).WithMany(p => p.StockInventoryorderItems)
                .HasForeignKey(d => d.CommodityCommodityId)
                .HasConstraintName("FKc1x6sikhuo1b7n0xjig8uduc");

            entity.HasOne(d => d.StockInventoryInventoryorder).WithMany(p => p.StockInventoryorderItems)
                .HasForeignKey(d => d.StockInventoryInventoryorderId)
                .HasConstraintName("FKfgw3hk1uk08d0v9fwy5erhl33");
        });

        modelBuilder.Entity<StockStock>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("stock_stock", tb => tb.HasComment("库存_库存"));

            entity.HasIndex(e => e.TenantId, "idx_stock_tenant_id");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.SytleNumber)
                .HasMaxLength(50)
                .HasComment("款号")
                .HasColumnName("sytle_number");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");
        });

        modelBuilder.Entity<StockStockDetail>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("stock_stock_details", tb => tb.HasComment("库存_库存_详情"));

            entity.HasIndex(e => e.StockStockId, "FKd907cuu7lgur5yb0acygfxpws");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Color)
                .HasMaxLength(50)
                .HasComment("颜色")
                .HasColumnName("color");
            entity.Property(e => e.Quantity)
                .HasComment("数量")
                .HasColumnName("quantity");
            entity.Property(e => e.Size)
                .HasMaxLength(50)
                .HasComment("尺码")
                .HasColumnName("size");
            entity.Property(e => e.StockStockId).HasColumnName("stock_stock_id");

            entity.HasOne(d => d.StockStock).WithMany(p => p.StockStockDetails)
                .HasForeignKey(d => d.StockStockId)
                .HasConstraintName("FKd907cuu7lgur5yb0acygfxpws");
        });

        modelBuilder.Entity<Student>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("Student");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
            entity.Property(e => e.TenantId).HasColumnName("tenantId");
        });

        modelBuilder.Entity<StudentActualCourse>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("StudentActualCourse");

            entity.HasIndex(e => e.CourseId, "FK91jecdxg99krraop5809atxlo");

            entity.HasIndex(e => e.StudentId, "FKit7pidi71ogy24fp8g4w8l5ju");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CourseId).HasColumnName("course_id");
            entity.Property(e => e.EnrollmentDate).HasColumnName("enrollmentDate");
            entity.Property(e => e.StudentId).HasColumnName("student_id");

            entity.HasOne(d => d.Course).WithMany(p => p.StudentActualCourses)
                .HasForeignKey(d => d.CourseId)
                .HasConstraintName("FK91jecdxg99krraop5809atxlo");

            entity.HasOne(d => d.Student).WithMany(p => p.StudentActualCourses)
                .HasForeignKey(d => d.StudentId)
                .HasConstraintName("FKit7pidi71ogy24fp8g4w8l5ju");
        });

        modelBuilder.Entity<UserAuthority>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("user_authority", tb => tb.HasComment("用户_角色_权限"));

            entity.HasIndex(e => e.ParentId, "FK7jpip0uj01jne5gjlxse58tbk");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Authority)
                .HasMaxLength(255)
                .HasComment("权限名称")
                .HasColumnName("authority");
            entity.Property(e => e.ParentId)
                .HasComment("上级id; 0 顶级")
                .HasColumnName("parent_id");
            entity.Property(e => e.RouterPath)
                .HasMaxLength(255)
                .HasComment("routerPath")
                .HasColumnName("router_path");
            entity.Property(e => e.SortNumber)
                .HasComment("排序编号")
                .HasColumnName("sort_number");

            entity.HasOne(d => d.Parent).WithMany(p => p.InverseParent)
                .HasForeignKey(d => d.ParentId)
                .HasConstraintName("FK7jpip0uj01jne5gjlxse58tbk");
        });

        modelBuilder.Entity<UserRole>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("user_role", tb => tb.HasComment("用户_主用户子用户_角色"));

            entity.HasIndex(e => e.TenantId, "FKemva74br7yl53m643k43ljdyc");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.RoleName)
                .HasMaxLength(100)
                .HasColumnName("role_name");
            entity.Property(e => e.TenantId).HasColumnName("tenant_id");

            entity.HasOne(d => d.Tenant).WithMany(p => p.UserRoles)
                .HasForeignKey(d => d.TenantId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("FKemva74br7yl53m643k43ljdyc");
        });

        modelBuilder.Entity<UserUser>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("user_user", tb => tb.HasComment("用户_用户"));

            entity.HasIndex(e => e.ParentId, "FKkgxrklnhhytwm4pf5rn3ya2l1");

            entity.HasIndex(e => e.PhoneNumber, "uc_user_phone_number").IsUnique();

            entity.HasIndex(e => e.Username, "uc_user_username").IsUnique();

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateDatetime)
                .HasComment("创建日期时间")
                .HasColumnType("datetime")
                .HasColumnName("create_datetime");
            entity.Property(e => e.Email)
                .HasMaxLength(50)
                .HasComment("电子邮件")
                .HasColumnName("email");
            entity.Property(e => e.IpAddress)
                .HasMaxLength(255)
                .HasComment("登录的ip地址")
                .HasColumnName("ip_address");
            entity.Property(e => e.LastLoginDatetime)
                .HasComment("最后登录时间")
                .HasColumnType("datetime")
                .HasColumnName("last_login_datetime");
            entity.Property(e => e.Nickname)
                .HasMaxLength(50)
                .HasComment("昵称")
                .HasColumnName("nickname");
            entity.Property(e => e.ParentId)
                .HasComment("上级id; 0 顶级")
                .HasColumnName("parent_id");
            entity.Property(e => e.Password)
                .HasMaxLength(50)
                .HasComment("密码")
                .HasColumnName("password");
            entity.Property(e => e.PhoneNumber)
                .HasMaxLength(11)
                .IsFixedLength()
                .HasComment("手机号码一键登录")
                .HasColumnName("phone_number");
            entity.Property(e => e.Platform)
                .HasMaxLength(255)
                .HasComment("登录的平台")
                .HasColumnName("platform");
            entity.Property(e => e.Status)
                .HasComment("0 欠费 1 正常 2 试用 3 禁用")
                .HasColumnName("status");
            entity.Property(e => e.Username)
                .HasComment("用户名")
                .HasColumnName("username");

            entity.HasOne(d => d.Parent).WithMany(p => p.InverseParent)
                .HasForeignKey(d => d.ParentId)
                .HasConstraintName("FKkgxrklnhhytwm4pf5rn3ya2l1");
        });

        modelBuilder.Entity<UserUserPicture>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("user_user_picture");

            entity.HasIndex(e => e.UserUserId, "UKcsf2g59adanqypguc1t8niht9").IsUnique();

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.ObjectKey)
                .HasMaxLength(1024)
                .HasComment("保存对象存储的key")
                .HasColumnName("object_key");
            entity.Property(e => e.UserUserId).HasColumnName("user_user_id");

            entity.HasOne(d => d.UserUser).WithOne(p => p.UserUserPicture)
                .HasForeignKey<UserUserPicture>(d => d.UserUserId)
                .HasConstraintName("FK33gth153n7qjxybvcuqj41vsq");
        });

        modelBuilder.Entity<UserUserVipsubscription>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("user_user_vipsubscription");

            entity.HasIndex(e => e.UserUserId, "FK5l44lgkdy3jqmy127j05p5ccj");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.EndDatetime)
                .HasComment("结束日期")
                .HasColumnType("datetime")
                .HasColumnName("end_datetime");
            entity.Property(e => e.IsTrial)
                .HasComment("0 false; 1 true")
                .HasColumnType("bit(1)")
                .HasColumnName("is_trial");
            entity.Property(e => e.StartDatetime)
                .HasComment("开始日期")
                .HasColumnType("datetime")
                .HasColumnName("start_datetime");
            entity.Property(e => e.UserUserId)
                .HasComment("用户_用户_id")
                .HasColumnName("user_user_id");

            entity.HasOne(d => d.UserUser).WithMany(p => p.UserUserVipsubscriptions)
                .HasForeignKey(d => d.UserUserId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("FK5l44lgkdy3jqmy127j05p5ccj");
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
